#!/bin/sh
# description: Start or Stop the i2c_fhem Prozes
### BEGIN INIT INFO
# Provides: sht21
# Required-Start: $all
# Required-Stop: $all
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: I2C 2 FHEM
### END INIT INFO

set -e
cd /opt/i2c_fhem
case "$1" in
'start')
	echo "Starting fhem_i2c..."
	./sht21>>/opt/fhem/log/sht.log&
	RETVAL=$?
	;;
'stop')
	echo "Stopping fhem_i2c..."
	pkill sht21
	RETVAL=$?
	;;
'status')
	cnt=`ps -ef | grep "sht21" | grep -v grep | wc -l`
	if [ "$cnt" -eq "0" ];
	then
		echo "i2c_fhem is not running"
	else
		echo "i2c_fhem is running"
	fi
	;;
*)
	echo "Usage: $0 (start | stop  |  status)"
	RETVAL=1
	;;
esac
exit $RETVAL

